/*
 * File:    AbstractWriteFuture.java
 * Created: 15-Nov-2007
 * 
 * by Kenji Hollis <kenji@bitgatesoftware.com>
 * Released under the Creative Commons License version 2.5
 */

package com.bitgate.util.socket;

import static com.bitgate.util.debug.Debug.debug;
import static com.bitgate.util.debug.Debug.isDebugEnabled;

/**
 * This is an abstract implementation of a {@link WriteFuture} object.
 * 
 * @author kenji
 * @since 0.6.1
 */
public class AbstractWriteFuture implements WriteFuture
{
	protected int bytesWritten;
	
	public AbstractWriteFuture() 
	{
		bytesWritten = 0;
	}
	
	/**
	 * This is a default "on completed" function callback.
	 */
	public void onComplete()
	{
		if (isDebugEnabled()) {
			debug("Write completed.");
		}
	}
	
	public void increaseByteCount(int count)
	{
		bytesWritten += count;
	}
	
	public void clearByteCount()
	{
		bytesWritten = 0;
	}
	
	public int getByteCount()
	{
		return bytesWritten;
	}
}